/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package co.com.javeriana.aes.oms.ejb.orders.dao;

 import java.sql.Connection;
 import java.sql.SQLException;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import javax.sql.DataSource;


/**
 *
 * @author Juan
 */
public class GenericDAO {

    /**
     * Metodo para crear y configurar una conexion!
     *
     * @return Se devuelve un objeto Connection con la conexion ya configurada!
     *
     * @throws NamingException !
     */
    public Connection getConnection() throws NamingException {
        Connection cnn = null;

        try {
            InitialContext initialContext = new InitialContext();
            DataSource ds = (DataSource) initialContext.lookup("java:jboss/datasources/omsds");
            try {
                cnn = ds.getConnection();
            } catch (SQLException sqle) {
                sqle.printStackTrace();
            }
        } catch (NamingException ne) {
            ne.printStackTrace();
        }

        return cnn;
    }
}
